GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmDiscontinuitySet Class Reference

Base interface for providing discontinuity geometry information for spatial indices. More...

#include <gmDiscontinuitySet.h>

Collaboration diagram for GmDiscontinuitySet:

Public Types

enum  DiscontinuityType {
  GM_DISC_POLYLINE , GM_DISC_TRISURFACE , GM_DISC_EDGELIST , GM_DISC_FACELIST ,
  GM_DISC_UNDEFINED
}
 Discontinuity type (defining how the disc. geometry is defined) More...
 
using SegmentCell2DIntersectionList = QVarLengthArray<GmCompact2DSegmentCellIntersection*, 1>
 Type for storing the set of 2D polyline-element intersections We use a QVarLengthArray since it has a smaller memory footprint than QVector If this type is changed (even if the pre alloc size of 1 is changed), please update GmDiscontinuitySet::usedElementMapMemory() accordingly.
 

Public Member Functions

 GmDiscontinuitySet (GmSimulationData *simData, QString id, QString description, GmCellMesh *mesh, GmSpatialIndex *index, bool addElements, bool addGhostNodes, bool extraDofs, double snapTol, double repelTol, double repelDistance, double parallelCosThreshold, bool noInternalNodes, bool internalIntersections, bool discardOriginalGeometry, bool extendGeometry, bool visibilityOnly)
 
 ~GmDiscontinuitySet ()
 Destructor.
 
QString id () const
 Returns the discontinuity set name.
 
QString description () const
 Returns the discontinuity set description.
 
DiscontinuityType type () const
 Returns the discontinuity geometry definition type.
 
GmCellMeshmesh () const
 Returns the mesh that this discontinuity set is tied to.
 
GmSpatialIndexspatialIndex () const
 Returns the mesh spatial index that this discontinuity set is tied to.
 
bool autoAddElements () const
 Returns true if the dicontinuity-cell intersections are added as new elements to the mesh.
 
bool autoAddGhostNodes () const
 Returns true if the dicontinuity-cell intersections are added as ghost nodes to the mesh.
 
bool extraDofsInAddedElements () const
 Returns true if added interface elements for type() == EDGELIST or FACELIST should have extra dof nodes.
 
double snapTolerance () const
 Returns the percentual tolerance used for snapping intersection points to nodes, edges or faces.
 
double repelTolerance () const
 Returns the percentual tolerance used for repelling intersection points from nodes.
 
double repelDistance () const
 Returns the percentual distance used for repelling intersection points from nodes.
 
bool noInternalNodes () const
 Return true if internal intersections between segments are "broken".
 
bool internalIntersections () const
 
bool discardOriginalGeometry () const
 Returns true if the original intersection geometry data will be discarded after intersection handling.
 
bool extendedOriginalGeometry () const
 Returns true if the original geometry was extended.
 
bool visibilityOnly () const
 Returns true if this discSet is for visibilityOnly (no mesh, index or intersections)
 
int numDiscontinuities () const
 Returns the number of discontinuities (lines) stored in the object.
 
const QVector< GmDiscontinuity * > & discontinuities () const
 Returns the stored list of discontinuities.
 
int startAddedNodeIndex () const
 
int discontinuityIndex (QString id) const
 Given a discontinuity id, finds its index in the set. Returns -1 if not found.
 
GmDiscontinuitydiscontinuity (int index)
 Returns the given discontinuity. Index shoulde be between 0 and numDiscontinuities() - 1.
 
const GmDiscontinuitydiscontinuity (int index) const
 Returns the given discontinuity as a const object. Index shoulde be between 0 and numDiscontinuities() - 1.
 
int dimension () const
 
bool intersects (const GmCell *c, bool def) const
 
QStringList attributeIds () const
 Returns a list with the id names for every attribute associated with the discontinuity set. No special order is enforced.
 
GmValueInfoattributeInfo (QString id) const
 Returns the metadata describing the discontinuity attribute named id If the id does not refer to a known attribute, returns NULL.
 
GmDiscontinuityAccessorattributeAccessor (QString id, Unit desiredUnit, const GmLogCategory &logger) const
 Creates an accessor object for the discontinuity attribute named id.
 
GmDiscontinuityAccessorattributeAccessor (QString id, int snum, bool locked, Unit desiredUnit, const GmLogCategory &logger) const
 Overloads attributeAccessor(QString, Unit, ...) to return an accessor for the requested previous state of a value.
 
int numAttributeStates (QString id) const
 Returns the number of existing states for the requested id or -1 if the id doesn't exists.
 
int numPropertySets () const
 Returns the number of property sets attached to this discontinuity set.
 
const QVector< GmPropertySet * > & propertySets () const
 Returns a reference to the list of property sets associated to this set.

 
int propertySetIndex (QString id) const
 
GmValueInfopropertyInfo (QString id) const
 Returns the metadata of the property named by id.
 
GmDiscontinuityAccessorpropertyAccessor (QString id, Unit desiredUnit, const GmLogCategory &logger) const
 Returns an accessor object for the property named by id.
 
bool buildIntersectionMaps (const GmLogCategory &logger)
 Builds the maps with element discontinuity segment intersections.
 
const SegmentCell2DIntersectionListcell2DPolylineIntersections (const GmCell *c) const
 Returns the set of 2D polyline - element intersections for cell c or an empty array if there is no intersection.
 
GmSegmentCell2DIntersectionCoordAccessorcell2DPolylineCoordAccessor (Unit desiredUnit, const GmLogCategory &logger) const
 Returns a "light" accessor that can be used to retrieve segment x cell intersection coordinate data in a different unit than the original mesh coordinate unit. As any accessor, the returned object should be properly disposed (deleted) by the caller. Returns NULL if the deired unit is incompatible with the mesh unit.
 
const Gm3DSurfaceCellIntersectioncell3DSurfaceIntersections (const GmCell *c) const
 Returns the set of 3D triangles - element intersections for cell c or an empty object if there is no intersection.
 
GmCell3DIntersectionCoordAccessorcell3DSurfaceCoordAccessor (Unit desiredUnit, const GmLogCategory &logger) const
 
const QMap< int, Gm3DSurfaceCellIntersectioncell3DSurfaceIntersectionsMap () const
 
bool loadFromDumpFile (QString dumpFile, GmSimulationData *data, const GmLogCategory &logger)
 
bool loadFromHdf5File (GmHdf5ModelReader *reader, int dsIndex, const GmLogCategory &logger)
 Loads discontinuity geometry information from the given Hdf5 file. The info pointer should correspond to the mesh discontinuity set information read using the given reader and the dsIndex should correspond to the current discontinuity set object.
 
bool loadFromTableAttrib (LuaTable &attrib, const GmLogCategory &logger, QVector< GmValueSet * > &outAttrib, int expectedSize=0)
 
bool loadFromTableProp (LuaTable &prop, const QMap< QString, GmPropertySet * > &propMap, const GmLogCategory &logger, QVector< GmPropertySet * > &outProp)
 
bool loadFromTableDisc (LuaTable &disc, const QVector< QSharedPointer< GmValueAccessor > > &attAcc, int type, const GmLogCategory &logger)
 
bool setAttributes (const QVector< GmValueSet * > &attrib)
 Setup discontinuity attributes/properties (1) only succeeds for empty discontinuitySet (2) takes pointers ownership if succeeds.
 
bool setProperties (const QVector< GmPropertySet * > &prop)
 
GmDiscontinuityaddDiscontinuity (QString id, DiscontinuityType dType, int *indexes, int ni, double *points, int np, const QVector< int > &propIndex, int cellGroupId=-1)
 Add a new discontinuity (1) only succeeds when intersections were not computed yet (2) takes pointers ownership if succeeds.
 
void printParameters (const GmLogCategory &logger, GmLogLevel level) const
 Prints discontinuity set basic information to the specified logger/level.
 
void print (const GmLogCategory &logger, GmLogLevel level) const
 Prints discontinuity set FULL information to the specified logger/level.
 
size_t printMemoryStatistics (const GmLogCategory &logger, GmLogLevel level) const
 Prints memory usage for this discontinuity set to the given logger. Returns the used memory as reported by usedMemory()
 
size_t usedMemory () const
 Returns an estimative of the memory used by the discontinuity set in bytes.
 
bool checkVisibility (const double *src, const double *dst, bool inclusive, double eps=3e-5) const
 
int getNumberOfDiscontinuities (const GmCell *c) const
 Returns the number of discontinuities that intersect a given element.
 
int getNumberOfDiscontinuityElements (const GmCell *c) const
 Returns the number of discontinuity elements (bar (2D)/triangle (3D)) that intersect a given element.
 
int getIdDiscontinuityElementInMesh (const GmCell *c, int k) const
 Return the id of the discontinuity element (bar (2D)/triangle (3D)) k inside the given cell in the mesh.
 
int getLocalIdDiscontinuityElement (const GmCell *c, int k) const
 Return the id of the discontinuity element (bar (2D)/triangle (3D)) k locally in the given cell.
 
void fillDiscontinuityNodesGlobalToLocalMap (const GmCell *c, QMap< int, int > &globalToLocal) const
 Fill the map with the global to local ids of the discontinuity elements nodes.
 
void fillDiscontinuityElementDofVector (int idMesh, const QMap< int, int > &dNodesGlobalToLocal, QVector< int > &dof) const
 Fill the vector dof with the global ids of the nodes of the discontinuity element k inside the given cell in the mesh.
 
void getDiscontinuityGeometry (const GmCell *e, int id, GmVector &Xref, GmMatrix &mn) const
 Get the discontinuity geometric properties.
 
void getPolylineDiscontinuityGeometry (const GmCell *e, int id, GmVector &Xref, GmMatrix &mn) const
 Get the discontinuity geometric properties of a polyline discontinuity.
 
void getTrisurfDiscontinuityGeometry (const GmCell *e, int id, GmVector &Xref, GmMatrix &mn) const
 Get the discontinuity geometric properties of a polyline discontinuity.
 
const QVector< GmVector3 > & consolidated3DPoints () const
 
const QVector< Gm3DSurfacePointInfo > & consolidated3DPointsInfo () const
 

Static Public Member Functions

static GmDiscontinuitySetloadFromTable (LuaTable &tab, GmSimulationData *data, int type, const GmLogCategory &logger)
 Loads a discontinuity set object full definition from a Lua table.
 
static DiscontinuityType getTypeFromTable (LuaTable &data)
 
static QString getTableFieldFromType (DiscontinuityType type)
 
static QString discontinuityTypeToStr (DiscontinuityType type)
 Returns a string representing the discontinuity geometric representation type.
 
static int strToDiscontinuityType (QString str)
 Returns the DiscontinuityType from the provided string or -1 if the type is unknown.
 
static double heavisideFunction (const GmVector &X, const GmVector &Xref, const GmVector &nd)
 Compute the heaviside function associated with a discontinuity given a reference point and its normal.
 

Private Member Functions

 GmDiscontinuitySet (QString id, QString description, DiscontinuityType type, GmCellMesh *mesh, GmSpatialIndex *index, bool addElements, bool addGhostNodes, bool extraDofs, double snapTol, double repelTol, double repelDistance, double parallelCosThreshold, bool noInternalNodes, bool internalIntersections, bool discardOriginalGeometry, bool extendGeometry, bool visibilityOnly, GmSimulationData *simData)
 Private constructor for use by loadFromTable.
 
bool addIntersectionsToMesh (const GmLogCategory &logger)
 
bool add2DSegmentCellIntersectionsToMesh (const GmLogCategory &logger)
 Add 2D mesh polyline intersections as new bar elements to the mesh.
 
bool add3DTriangleCellIntersectionsToMesh (const GmLogCategory &logger)
 Add 3D triangle surface intersections as new tri3 elements to the mesh.
 
bool addGhostNodeIntersectionsToMesh (const GmLogCategory &logger)
 
bool break2DPolylinesAtIntersections (const GmLogCategory &logger)
 Break discontinuity intersection "bars" when they intersect with other discontinuities.
 
bool extendGeometry (const GmLogCategory &logger)
 
size_t encDiscPoint (int discId, int pointId) const
 
int push3DPoint (int discId, int pointId, GmIntersectionPointType ptype, const GmVector3 &point)
 
int get3DPoint (int discId, int pointId) const
 
void computeAxis (GmVector3 &normal, GmVector3 &tan) const
 
void removeUnused3DPoints ()
 
bool consolidate3DSurfIntersections (const GmLogCategory &logger)
 
void buildVisibilityBVH (const GmLogCategory &logger)
 
QVector< QVector< int > > & getCellEEFaceMap (const GmCellType type)
 
size_t usedElementMapMemory () const
 
void initResultAttributes (GmSimulationData *simulation)
 
 Q_DISABLE_COPY (GmDiscontinuitySet)
 
void DebugCells ()
 

Private Attributes

QString _id
 The discontinuity set id (name)
 
QString _description
 A description of the discontinuity set.
 
DiscontinuityType _type
 The type of the discontinuities geometric data.
 
GmCellMesh_mesh
 The mesh that this discontinuity set is tied to.
 
GmSpatialIndex_index
 The optional spatial index used to speedup queries.
 
bool _addElements
 Should we automatically add the discontinuity geometry - cell intersections as elements to the mesh?
 
bool _addGhostNodes
 Should we automatically add the discontinuity geometry as ghost nodes?
 
bool _addedInterfElemHaveExtraDofs
 Should added interface elements for EDGELIST/FACELIST have extra dof nodes?
 
double _snapTol
 The percentual snap tolerance for atracting intersection points to nodes, edges or faces.
 
double _repelTol
 The percentual tolerance for repeling a intersection point from a node. (Used for GmTriSurfaceDiscontinuity)
 
double _repelDistance
 The percentual distance for repeling a intersection point from a node detected by repelTol.
 
double _parallelCosThreshold
 The cosine threshold used to detect parallelism between surfaces.
 
bool _noInternalNodes
 Flag controlling if internal nodes are allowed (false) or not (true) in the intersection segments.
 
bool _internalIntersections
 Flag controlling if internal intersections should be handled or not.
 
bool _discardOriginalGeometry
 Flag controlling if the original geometry should be discarded after intersection handling for memory saving.
 
bool _extendGeometry
 Flag controlling if the original geometry should be expanded before computing intersections.
 
bool _intersectionsBuilt
 Signals if intersections are built, aftewards no data changes are allowed.
 
bool _visibilityOnly
 Flag for discontinuity with only visibility test (no intersections computed)
 
QVector< GmValueSet * > _attributes
 List with the set of defined attribute values.
 
QVector< GmPropertySet * > _propertySets
 List with the associated property sets.
 
QVector< GmDiscontinuity * > _data
 The list with discontinuity data.
 
QMap< QString, int > _attributesMap
 Maps attribute ids to their indices in _attributes.
 
QMap< QString, int > _dataMap
 Maps discontinuity names to their indices in _data.
 
QMap< int, SegmentCell2DIntersectionList_elementPolylineIntersectionsMap
 The map with per element intersections with polyline discontinuities.
 
QMap< int, Gm3DSurfaceCellIntersection_elementSurfaceIntersectionMap
 
QHash< GmCellType, QVector< QVector< int > > > _cellEEFaceMap
 
GmBVHVisibility_visibilityBVH
 Acceleration structure for visibility queries.
 
GmSimulationData_simData
 
int _startNode
 When elementts are added to mesh, this points to the starting added node.
 
QMap< size_t, int > _pointMapId
 Map used to translate local point to global points list.
 
QVector< GmVector3_consolidatedPoints
 List of consolidated points from 'consolidate3DSurfIntersections'.
 
QVector< Gm3DSurfacePointInfo_consolidatedPointsInfo
 

Static Private Attributes

static int _dsItem = -1
 
static int _buildItem = -1
 
static int _extendGItem = -1
 
static int _intersecItem = -1
 
static int _consol3Ditem = -1
 
static int _add2MeshItem = -1
 
static int _buildVisItem = -1
 

Friends

class GmDiscontinuitySetStateDumpItem
 Dump related operators.
 
class GmLuaDiscontinuitySet
 
QDataStreamoperator<< (QDataStream &stream, const GmDiscontinuitySet &ds)
 
QDataStreamoperator>> (QDataStream &stream, GmDiscontinuitySet &ds)
 

Detailed Description

Base interface for providing discontinuity geometry information for spatial indices.

Member Enumeration Documentation

◆ DiscontinuityType

Discontinuity type (defining how the disc. geometry is defined)

Enumerator
GM_DISC_POLYLINE 

The disc. geometry is given by a polyline. Inserted elements are bars.

GM_DISC_TRISURFACE 

The disc. geometry is given by a trinagulated surface. Inserted elements are triangles or quads.

GM_DISC_EDGELIST 

The disc. geometry is given by an edge list. Inserted elements are 2d interface elements.

GM_DISC_FACELIST 

The disc. geometry is given by a face list. Inserted elements are 3d interface elements.

Member Function Documentation

◆ attributeAccessor() [1/2]

GmDiscontinuityAccessor * GmDiscontinuitySet::attributeAccessor ( QString id,
int snum,
bool locked,
Unit desiredUnit,
const GmLogCategory & logger ) const

Overloads attributeAccessor(QString, Unit, ...) to return an accessor for the requested previous state of a value.

The snum parameter contains the requested state. A value of zero means the current state, 1 the previous one, 2 the one before that and so on. Valid values range from zero to the oldest state for the requested variable. Remember that for a value accessor to support states, the history parameter must be set in its value info object.

The locked parameter controls the behaviour of the accessor once a new state is created for the value. The 'lock' refers to the state number, so if locked is false and a new state is created, the accessor doesn't change and continues to point to the same data. If locked is true, the accessor will be locked to that state number so when a new state is created, the accessor changes the data its looking upon to reflect the new satte. For example, an accessor locked on the state 0 will always point to the current state and one locked to the state 1 will always point to the previous saved value.

See the overloaded function for the remaining parameters.

◆ attributeAccessor() [2/2]

GmDiscontinuityAccessor * GmDiscontinuitySet::attributeAccessor ( QString id,
Unit desiredUnit,
const GmLogCategory & logger ) const

Creates an accessor object for the discontinuity attribute named id.

If the id does not refer to a known attribute, returns NULL.

If desiredUnit is a known unit, different from the basic attribute unit, the value will be automatically converted to the desired unit. If no conversion is possible, the function returns NULL. To avoid conversions, just pass Unit() as the desiredUnit.

IMPORTANT: The returned accessor should be deallocated by the caller.

Obs: This is equivalent to calling attributeAccessor(id, 0, true, desiredUnit, logger)

◆ break2DPolylinesAtIntersections()

bool GmDiscontinuitySet::break2DPolylinesAtIntersections ( const GmLogCategory & logger)
private

Break discontinuity intersection "bars" when they intersect with other discontinuities.

The aux data temporarily saved for each intersection

< The list index for the intersecting segment

< The "natural" coordinate for the intersection

< The cartesian coordinate for the intersection

◆ consolidate3DSurfIntersections()

bool GmDiscontinuitySet::consolidate3DSurfIntersections ( const GmLogCategory & logger)
private

Later on we assume that it is negative!

◆ getDiscontinuityGeometry()

void GmDiscontinuitySet::getDiscontinuityGeometry ( const GmCell * e,
int id,
GmVector & Xref,
GmMatrix & mn ) const

Get the discontinuity geometric properties.

Get the discontinuity geometric properties Fill the reference point Xref and the orientation vectors, saved in the matrix mn, of the discontinuity that intersects the given cell.

◆ getNumberOfDiscontinuities()

int GmDiscontinuitySet::getNumberOfDiscontinuities ( const GmCell * c) const

Returns the number of discontinuities that intersect a given element.

Returns the number of discontinuities that intersect the given cell.

◆ getNumberOfDiscontinuityElements()

int GmDiscontinuitySet::getNumberOfDiscontinuityElements ( const GmCell * c) const

Returns the number of discontinuity elements (bar (2D)/triangle (3D)) that intersect a given element.

Returns the number of discontinuity subelements that intersect a given element. The sub-elements consist in the bars for 2D and triangles for 3D.

◆ intersects()

bool GmDiscontinuitySet::intersects ( const GmCell * c,
bool def ) const

Returns true if this discontinuitySet cross the given cell (completely cross) IMPORTANT: In case the cell is from another mesh returns the default value

◆ loadFromHdf5File()

bool GmDiscontinuitySet::loadFromHdf5File ( GmHdf5ModelReader * reader,
int dsIndex,
const GmLogCategory & logger )

Loads discontinuity geometry information from the given Hdf5 file. The info pointer should correspond to the mesh discontinuity set information read using the given reader and the dsIndex should correspond to the current discontinuity set object.

A 2d or 3d border discontinuity (edge list or face list)

◆ loadFromTable()

GmDiscontinuitySet * GmDiscontinuitySet::loadFromTable ( LuaTable & tab,
GmSimulationData * data,
int type,
const GmLogCategory & logger )
static

Loads a discontinuity set object full definition from a Lua table.

The new object is initialized with the data found in the table. Returns NULL and prints an error message using the supplied logger in case of errors (like an invalid disc. set definition point or boundary).

If type is different from -1, assumes that its value is the DiscontinuityType and DOES NOT LOADS the polyline, boundary or surface data.

This function expects that some basic validation steps have been done elsewhere (currently at the model loading by the DiscontinuitySet Lua function).

◆ propertyAccessor()

GmDiscontinuityAccessor * GmDiscontinuitySet::propertyAccessor ( QString id,
Unit desiredUnit,
const GmLogCategory & logger ) const

Returns an accessor object for the property named by id.

If id does not reference a known property, returns NULL; Remember that there should be no intersection between property names of the several sets bound to a single discontinuity set, so id specifies a unique property among the several possible property sets.

If desiredUnit is a known unit, different from the basic property unit, the value will be automatically converted to the desired unit. If no conversion is possible, the function returns NULL. To avoid conversions, just pass Unit() as the desiredUnit.

IMPORTANT: The returned accessor should be deallocated by the caller.

◆ propertyInfo()

GmValueInfo * GmDiscontinuitySet::propertyInfo ( QString id) const

Returns the metadata of the property named by id.

If id does not reference a known property, returns NULL; Rememeber that there should be no intersection between property names of the several sets bound to a single discontinuity set, so id specifies a unique property among the several possible property sets.

◆ propertySetIndex()

int GmDiscontinuitySet::propertySetIndex ( QString id) const

Returns the index in the list returned by propertySets() of the set that includes the named property.

If the id does not reference a known property, returns -1; Rememeber that there should be no intersection between property names of the several sets bound to a single discontinuity set, so id specifies a unique property among the several possible property sets.

◆ propertySets()

const QVector< GmPropertySet * > & GmDiscontinuitySet::propertySets ( ) const
inline

Returns a reference to the list of property sets associated to this set.

The order of the property sets in the list is consistent with results returned from propertySetIndex(), i.e, if a call to propertySetIndex("a") returns 1, the second entry of the list should be the property set that includes the "a" property.

◆ repelDistance()

double GmDiscontinuitySet::repelDistance ( ) const
inline

Returns the percentual distance used for repelling intersection points from nodes.

Returns true if internal nodes are not allowed in the intersection segments (except for internal segment intersections)

◆ usedMemory()

size_t GmDiscontinuitySet::usedMemory ( ) const

Returns an estimative of the memory used by the discontinuity set in bytes.

It returns in general the variable memory that depends on the number of discontinuities ignoring "constant" sizes.

Member Data Documentation

◆ _consolidatedPointsInfo

QVector<Gm3DSurfacePointInfo> GmDiscontinuitySet::_consolidatedPointsInfo
private

List of info for consolidated points from 'consolidate3DSurfIntersections'

◆ _simData

GmSimulationData* GmDiscontinuitySet::_simData
private

We need the simulation data to create the temp mesh used for geometry extension As we can only have 8 meshes, we need to create/delete it only when extension is done


The documentation for this class was generated from the following files: